<?php
$r_url = "admin.php?file=userjs";
#[判断权限]
if($_SESSION["admin"]["typer"] != "system" && !$QG_AP["users"])
{
	Error("对不起，您没有权限操作当前功能","admin.php?file=index");
}
if($sysact == "add" || $sysact == "modify")
{
	if($sysAct == "modify")
	{
		$id = intval($id);
		if(!$id)
		{
			Error("操作非法！","admin.php?file=userjs&act=list");
		}
		$rs = $DB->qgGetOne("SELECT * FROM soldier WHERE s_id='".$id."'");
		$rsa = $DB->qgGetOne("SELECT c_name FROM city WHERE c_id='".$rs[c_id]."'");
		$rsb = $DB->qgGetOne("SELECT p_nickname FROM player_info WHERE u_id='".$rs[u_id]."'");
	
	}
}
elseif($sysact == "viewok")
{
	$id = intval($id);
	$msg = $STR->safe($_POST);
	if($id)
	{
		$sql = "UPDATE soldier SET bu_zhu='".$msg["bu_zhu"]."',tan_zhi='".$msg["tan_zhi"]."',zz_bing='".$msg["zz_bing"]."',pd_shou='".$msg["pd_shou"]."',dg_shou='".$msg["dg_shou"]."',be_shi='".$msg["be_shi"]."',bmy_chong='".$msg["bmy_chong"]."',zc_dui='".$msg["zc_dui"]."',xds_shi='".$msg["xds_shi"]."',zz_che='".$msg["zz_che"]."',xz_ying='".$msg["xz_ying"]."',jwj_bing='".$msg["jwj_bing"]."',xlt_qi='".$msg["xlt_qi"]."',wdf_jun='".$msg["wdf_jun"]."',hb_qi='".$msg["hb_qi"]."',pl_che='".$msg["pl_che"]."',np_che='".$msg["np_che"]."'  WHERE s_id='".$id."'";
		$DB->qgQuery($sql);		
		$r_url = $_SESSION["return_url"] ? $_SESSION["return_url"] : $r_url."&act=list";
		Error("军事信息更新成功",$r_url);
	}
	else
	{
		$sql = "SELECT c_id FROM ".$prefix."soldier WHERE c_id='".$msg["c_id"]."'";
		$rschk = $DB->qgGetOne($sql);
		if($rschk)
		{
			Error("城池军队 ".$msg["username"]." 已经存在",$r_url."&act=add");
		}
		$sql = "INSERT INTO ".$prefix."soldier (s_id,u_id,c_id,bu_zhu,tan_zhi,zz_bing,pd_shou,dg_shou,be_shi,bmy_chong,zc_dui,xds_shi,zz_che,xz_ying,jwj_bing,xlt_qi,wdf_jun,hb_qi,pl_che,np_che) VALUES('',u_id='".$msg["u_id"]."',c_id='".$msg["c_id"]."',bu_zhu='".$msg["bu_zhu"]."',tan_zhi='".$msg["tan_zhi"]."',zz_bing='".$msg["zz_bing"]."',pd_shou='".$msg["pd_shou"]."',dg_shou='".$msg["dg_shou"]."',be_shi='".$msg["be_shi"]."',bmy_chong='".$msg["bmy_chong"]."',zc_dui='".$msg["zc_dui"]."',xds_shi='".$msg["xds_shi"]."',zz_che='".$msg["zz_che"]."',xz_ying='".$msg["xz_ying"]."',jwj_bing='".$msg["jwj_bing"]."',xlt_qi='".$msg["xlt_qi"]."',wdf_jun='".$msg["wdf_jun"]."',hb_qi='".$msg["hb_qi"]."',pl_che='".$msg["pl_che"]."',np_che='".$msg["np_che"]."')";
		$DB->qgQuery($sql);
		Error("新建军队信息成功");
	}
}
elseif($sysact == "delete")
{
	$r_url = $_SESSION["return_url"] ? $_SESSION["return_url"] : $r_url."&act=list";
	$id = intval($id);
	if(!$id)
	{
		Error("操作非法",$r_url);
	}
	$sql = "DELETE FROM ".$prefix."city WHERE c_id='".$id."'";
	$DB->qgQuery($sql);
	Error("会员信息删除成功",$r_url);
}
elseif($act == "list")
{
	$page_url = "admin.php?file=userjs&act=list";
	$psize = 20;
	$pageid = intval($pageid);
	$offset = $pageid>0 ? ($pageid-1)*$psize : 0;
	$condition = "WHERE 1";
	$keywords = SafeHtml($keywords);
	$stype = SafeHtml($stype);
	if($keywords)
	{
		if($stype == "c_id")
		{
			$condition .= " AND c_id LIKE '%".$keywords."%'";
		}
		elseif($stype == "s_id")
		{
			$condition .= " AND s_id LIKE '%".$keywords."%'";
		}
		elseif($stype == "u_id")
		{
			$condition .= " AND u_id LIKE '%".$keywords."%'";
		}
		$page_url .= "&stype=".rawurlencode($stype)."&keywords=".rawurlencode($keywords);
	}
	$count = $DB->qg_count("SELECT count(c_id) FROM ".$prefix."city ".$condition);
	$pagelist = page($page_url,$count,$psize,$pageid);#[获取页数信息]
	$rslist = $DB->qgGetAll("SELECT * FROM ".$prefix."soldier ".$condition." ORDER BY c_id DESC LIMIT ".$offset.",".$psize);
}
Foot("userjs.qg");
?>